home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
signal
/
c
/
sigsuspend
< prev
next >
Wrap
Text File
|
1996-11-09
|
2KB
|
64 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/signal/c/RCS/sigsuspend,v $
* $Date: 1996/10/30 22:04:51 $
* $Revision: 1.1 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: sigsuspend,v $
* Revision 1.1 1996/10/30 22:04:51 unixlib
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: sigsuspend,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
/* Written by Nick Burrett, 26 Aug 1996. */
#include <errno.h>
#include <signal.h>
#include <stddef.h>
#include <unistd.h>
#include <sys/unix.h>
/* Change the set of blocked signals to SET,
wait until a signal arrives, and restore the set of blocked signals. */
int sigsuspend (const sigset_t *set)
{
sigset_t oset;
if (set == NULL)
{
errno = EINVAL;
return -1;
}
if (sigprocmask(SIG_SETMASK, set, &oset) < 0)
return -1;
/* Set the process sleeping. Then wait until this is unset by something
else. A process calling sigsuspend will usually be woken up after
delivery of a SIGSTOP signal or after any other signal and any pending
ones have been delivered. */
__u->sleeping = 1;
/* Bit of a silly busy wait this is. But unfortunately we aren't under a
tasking system so it's not really possible to have a SWI Wimp_Poll
call here. */
#ifdef DEBUG
printf ("sigsuspend: Process suspended. Waiting for a signal.\n");
#endif
while (__u->sleeping)
;
#ifdef DEBUG
printf ("sigsuspend: Signal received. Process continuing\n");
#endif
if (sigprocmask(SIG_SETMASK, &oset, (sigset_t *) NULL) < 0)
return -1;
errno = EINTR;
return -1;
}